package com.itwlj.controller.user;

import com.itwlj.result.Result;
import com.itwlj.service.PayService;
import com.itwlj.vo.PayVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 支付
 */
@RestController
@RequestMapping("/pay")
@Api(tags = "C端支付相关接口")
@Slf4j
public class PayController {

    @Autowired
    private PayService payService;

    /**
     * 支付预览
     *
     * @return
     */
    @GetMapping("/order/{id}")
    @ApiOperation("支付预览")
    public Result<PayVO> getPayPreview(@PathVariable Long id) {
        return Result.success(payService.getPayPreview(id));
    }

    /**
     * 支付订单
     *
     * @param id
     * @return
     */
    @PostMapping("/{id}")
    @ApiOperation("支付订单")
    public Result<Map> payOrder(@PathVariable Long id, @RequestParam String password) {
        payService.payOrder(id, password);
        return Result.success();
    }
}
